#include "starscence.h"
#include "selectscene.h"
#include<QPushButton>
#include "mypushbutton.h"
#include <QTimer>
StearScence::StearScence(QWidget *parent)
    : myMainWindow{parent}
{
    this->setWindowTitle("开始场景");

    MyPushButton *btnStart = new MyPushButton(":/res/MenuSceneStartButton.png", ":/res/MenuSceneStartButton.png",this);
    btnStart->resize(114,114);

    //按钮水平居中
    btnStart->move((this->width()-btnStart->width())/2,
                   this->height()*3/4-btnStart->height()/2);

    connect(&this->mSelectscene, &selectScene::backBtnClicked,[=](){
        //当第二个窗口的返回按钮点击的时候，显示当前窗口，隐藏第二个窗口
        this->show();
        this->mSelectscene.hide();
        this->move(this->mSelectscene.pos());
    });

    connect(btnStart,&MyPushButton::clicked,[=]{
        //播放向下的动画
        btnStart->moveDown();

        QTimer::singleShot(150,[=]{
            //往上走的动画会覆盖之前的动画
            //要等待之前动画播放完在调用

            btnStart->moveUp();

            });

        QTimer::singleShot(300,[=]{
            //将按钮设置为可用

            btnStart->setEnabled(true);


            //场景转换，隐藏当前窗口
            this->hide();
            //显示第二个窗口
            this->mSelectscene.show();
            //将窗口翻动到当前窗口的位置
            this->mSelectscene.move(this->pos());

        });


        });
}
